<?php

namespace App\Jobs;

use App\Service\TestService;
use Hhxsv5\LaravelS\Swoole\Task\Task;
use Illuminate\Support\Facades\Log;

class yibuTask extends Task
{

    private $data;
    private $result;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        //
        $this->data=$data;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $service=new TestService();
        $service->yiburenwu($this->data);
        $this->result='123';
        echo '123123';
    }
    // 任务完成调用 finish 回调时触发，等同于 Swoole 中的 onFinish 逻辑
    public function finish()
    {

        Log::info(__CLASS__ .strtotime("now") .': 任务处理完成', [$this->result]);
        // 可以在这里触发后续要执行的任务，或者执行其他善后逻辑
    }
}
